package com.quectel.core.module.parkingcard.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.quectel.core.module.parkingcard.entity.ParkingCardOrderDeviceEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author ryan
 * @email ryan.ran@quectel.com
 * @date 2023/04/24 15:24
 */

public interface ParkingCardOrderDeviceDao extends BaseMapper<ParkingCardOrderDeviceEntity> {

    /**
     * 查询列表
     *
     * @param params
     * @return
     */
    List<ParkingCardOrderDeviceEntity> queryList(Map<String, Object> params);

    /**
     * 查询数量
     *
     * @param params
     * @return
     */
    int queryTotal(Map<String, Object> params);

    @Select("<script>select pcod.*, d.name as device_name from (select * from parking_card_order_device where parking_card_order_id = #{orderId}) pcod LEFT JOIN device d on pcod.device_id = d.id" +
            "</script>")
    List<ParkingCardOrderDeviceEntity> selectByOrderId(@Param("orderId") Long orderId);
}
